import random,math,sys,time,signal
import pygame
pygame.init()
screen=pygame.display.set_mode((640,640))
pygame.mixer.init()
sound_fail=pygame.mixer.Sound(r".\resource\fail.wav")
def f(comment,a,x,y,r,g,b):
    f=pygame.font.Font(r".\resource\STXINGKA.TTF",a)
    text=f.render(comment,True,(r,g,b))
    screen.blit(text,(x,y))
font=pygame.font.Font(None,30)
back=pygame.image.load(r".\resource\星空(1).png").convert_alpha()
def f2(comment,a,x,y,r,g,b):
    global font
    text=font.render(comment,False,(r,g,b))
    screen.blit(text,(x,y))
class qi():
    def __init__(self,xy):
        self.xy=xy
        self.s=0

def z(x,y,t):
    v=0
    for i in t:
        if (i[0]+x,i[1]+y) in t:
            if (i[0]+2*x,i[1]+2*y) in t:
                if (i[0]+3*x,i[1]+3*y) in t:
                    if (i[0]+4*x,i[1]+4*y) in t:
                        v=1
                        
                       
    if v==0 :
        return False
    elif v==1:
        return True
  
def zz(first,xy1=[],xy2=[],t1=[],xy3=[],xy4=[],t2=[]):#存在，不存在,xy大于0
    
    v=0
    for xy2_k in xy2:
            if (first[0]+xy2_k[0],first[1]+xy2_k[1])in t1:
                v=1
    for xy1_k in xy1:
        if (first[0]+xy1_k[0],first[1]+xy1_k[1])not in t1:
            v=1
    for xy4_k in xy4:
        if (first[0]+xy4_k[0],first[1]+xy4_k[1])in t2:
            v=1
    for xy3_k in xy3:
        if (first[0]+xy3_k[0],first[1]+xy3_k[1])not in t2:
            v=1
    if v==1:
        return False
    elif v==0:
        return True

judge=[]


#others=0
judge=[[(3,1,1,1,1),7],[(1,3,1,1,1),7],[(1,1,3,1,1),6],#11111
       [(0,3,1,1,1,0),5],[(0,1,3,1,1,0),5],#011110
       [(0,3,1,1,0),3.5],[(0,1,3,1,0),2.5],#01110

       [(2,3,1,1,1,0),4],[(2,1,3,1,1,0),4],[(2,1,1,3,1,0),4],[(2,1,1,1,3,0),4],#211110
       
       [(0,3,1,0,1,1,0),4],[(0,1,3,0,1,1,0),4],#0110110
       [(0,3,1,1,0,1,0),4],[(0,1,3,1,0,1,0),4],[(0,1,1,3,0,1,0),4],[(0,1,1,1,0,3,0),4],#0111010
       [(2,3,0,1,1,1,0),3.5],[(2,1,0,3,1,1,0),3.5],[(2,1,0,1,3,1,0),3.5],[(2,1,0,1,1,3,0),3.5],#2101110
       [(2,3,1,0,1,1,0),3.5],[(2,1,3,0,1,1,0),3.5],[(2,1,1,0,3,1,0),3.5],[(2,1,1,0,1,3,0),3.5],#2110110
       [(2,3,1,1,0,1,0),3.5],[(2,1,3,1,0,1,0),3.5],[(2,1,1,3,0,1,0),3.5],[(2,1,1,1,0,3,0),3.5],#2111010
       [(2,3,0,1,1,1,2),3],[(2,1,0,3,1,1,2),3],[(2,1,0,1,3,1,2),3],[(2,1,0,1,1,3,2),3],#2101112
       [(2,3,1,0,1,1,2),3],[(2,1,3,0,1,1,2),3],#2110112
       
       [(0,3,0,1,0,1,0),2.5],[(0,1,0,3,0,1,0),1.5],#0101010
       [(0,3,1,0,0,1,0),2.5],[(0,1,3,0,0,1,0),2.5],[(0,1,1,0,0,3,0),2.5],#0110010
       [(2,3,0,1,0,1,0),2],[(2,1,0,3,0,1,0),2],[(2,1,0,1,0,3,0),2],#2101010
       [(2,3,1,0,0,1,0),2],[(2,1,3,0,0,1,0),2],[(2,1,1,0,0,3,0),2],#2110010
       [(2,3,0,0,1,1,0),2],[(2,1,0,0,3,1,0),2],[(2,1,0,0,1,3,0),2],#2100110
       [(2,3,0,0,1,1,2),1.5],[(2,1,0,0,3,1,2),1.5],[(2,1,0,0,1,3,2)],#2100112
       [(2,3,0,1,0,1,2),1.5],[(2,1,0,3,0,1,2),0.5],#2101012
       
       

       [(2,3,1,1,0),2],[(2,1,3,1,0),2],[(2,1,1,3,0),2],#21110
       [(0,3,1,0,1,0),2],[(0,1,3,0,1,0),2],[(0,1,1,0,3,0),2],#011010
       [(2,3,1,0,1,0),2],[(2,1,3,0,1,0),2],[(2,1,1,0,3,0),2],#211010
       [(2,3,0,1,1,0),2],[(2,1,0,3,1,0),2],[(2,1,0,1,3,0),2],#210110
       
       [(0,3,1,0),1.5],#0110
       [(2,3,1,0),1],[(2,1,3,0),1],#2110
       [(0,3,0,1,0),1],#01010
       [(2,3,0,1,0),0.5],[(2,1,0,3,0),0.5],#21010
       [(0,3,0,0,1,0),0.5]#010010
       ]
judge1=[[(0,1,1,1,0,3,0),4],[(2,1,1,1,0,3,0),3.5],[(0,3,0,1,0,1,0),2.5],[(0,1,0,3,0,1,0),1.5],[(0,1,1,0,0,3,0),2.5],
        [(2,1,0,3,0,1,0),2],[(2,1,0,1,0,3,0),2],[(2,1,1,0,0,3,0),2],[(2,1,0,3,0,1,2),0.5],[(0,1,1,0,3,0),2],
        [(2,1,1,0,3,0),2],[(0,3,0,1,0),1],[(2,1,0,3,0),0.5],[(0,3,0,0,1,0),0.5]]#00

judge2=[[(0, 3, 1, 1, 1, 0), 5], [(0, 3, 1, 1, 0), 3.5], [(0, 3, 1, 0, 1, 1, 0), 4], [(0, 3, 1, 1, 0, 1, 0), 4],
         [(2, 1, 0, 3, 1, 1, 0), 3.5], [(2, 1, 1, 0, 3, 1, 0), 3.5], [(2, 1, 0, 3, 1, 1, 2), 3],
         [(0, 3, 1, 0, 0, 1, 0), 2.5], [(2, 1, 0, 0, 3, 1, 0), 2],[(2, 1, 0, 0, 3, 1, 2), 1.5],
        [(0, 3, 1, 0, 1, 0), 2], [(2, 1, 0, 3, 1, 0), 2], [(0, 3, 1, 0), 1.5],[(3, 1, 1, 1, 1), 7]]#01

judge3=[[(1, 3, 1, 1, 1), 7], [(1, 1, 3, 1, 1), 6], [(0, 1, 3, 1, 1, 0), 5], [(0, 1, 3, 1, 0), 2.5],
        [(2, 1, 3, 1, 1, 0), 4], [(2, 1, 1, 3, 1, 0), 4], [(0, 1, 3, 1, 0, 1, 0), 4], [(2, 1, 0, 1, 3, 1, 0), 3.5],
        [(2, 1, 3, 1, 0, 1, 0), 3.5], [(2, 1, 0, 1, 3, 1, 2), 3], [(2, 1, 3, 1, 0), 2],[(3, 1, 1, 1, 1), 7]]#11

judge4=[[(2, 1, 1, 1, 3, 0), 4], [(0, 1, 3, 0, 1, 1, 0), 4], [(0, 1, 1, 3, 0, 1, 0), 4],
        [(2, 1, 0, 1, 1, 3, 0), 3.5], [(2, 1, 3, 0, 1, 1, 0), 3.5], [(2, 1, 1, 0, 1, 3, 0), 3.5],
        [(2, 1, 1, 3, 0, 1, 0), 3.5], [(2, 1, 3, 0, 1, 1, 2), 3], [(0, 1, 3, 0, 0, 1, 0), 2.5],
        [(2, 1, 3, 0, 0, 1, 0), 2], [(2, 1, 0, 0, 1, 3, 0), 2], [(2, 1, 1, 3, 0), 2],[(0, 1, 3, 0, 1, 0), 2],
        [(2, 1, 3, 0, 1, 0), 2], [(2, 1, 0, 1, 3, 0), 2], [(2, 1, 3, 0), 1]]#10

judge5=[[(2, 3, 0, 1, 1, 1, 0), 3.5], [(2, 3, 0, 1, 1, 1, 2), 3], [(2, 3, 0, 1, 0, 1, 0), 2], [(2, 3, 0, 0, 1, 1, 0), 2],
        [(2, 3, 0, 0, 1, 1, 2), 1.5],
        [(2, 3, 0, 1, 0, 1, 2), 1.5], [(2, 3, 0, 1, 1, 0), 2], [(2, 3, 0, 1, 0), 0.5]]#20

judge6=[[(2, 1, 0, 1, 1, 3, 2), 3], [(2, 1, 0, 0, 1, 3, 2)]]#12

judge7=[[(2, 3, 1, 1, 1, 0), 4], [(2, 3, 1, 0, 1, 1, 0), 3.5], [(2, 3, 1, 1, 0, 1, 0), 3.5],[(2, 3, 1, 0, 1, 1, 2), 3],
        [(2, 3, 1, 0, 0, 1, 0), 2], [(2, 3, 1, 1, 0), 2], [(2, 3, 1, 0, 1, 0), 2], [(2, 3, 1, 0), 1],[(3, 1, 1, 1, 1), 7]]#21

judges=[judge1,judge2,judge3,judge4,judge5,judge6,judge7]
def zzz(s,x,y,o,k):
    global judges
    p=0
    r=[]
    for i in range(-1,16):
        r.append((-1,i))
        r.append((i,-1))
        r.append((15,i))
        r.append((i,15))
    run=True
    final=[]
    if (((s[0]-x,s[1]-y)in k+r)and((s[0]+4*x,s[1]+4*y)in k+r))or(((s[0]-2*x,s[1]-2*y)in k+r)and((s[0]+3*x,s[1]+3*y)in k+r)):
        run=False
    if (((s[0]-x,s[1]-y)in k+r)and((s[0]+3*x,s[1]+3*y)in k+r))or(((s[0]-2*x,s[1]-2*y)in k+r)and((s[0]+2*x,s[1]+2*y)in k+r)):
        run==False
    if (((s[0]-x,s[1]-y)in k+r)and((s[0]+2*x,s[1]+2*y)in k+r))or(((s[0]-x,s[1]-y)in k+r)and((s[0]+x,s[1]+y)in k+r)):
        run==False

    if ((s[0]-x,s[1]-y)not in o+k+r)and((s[0]+x,s[1]+y)not in o+k+r):
        final=judges[0]
        if((s[0]-2*x,s[1]-2*y)not in o+k+r)and((s[0]+2*x,s[1]+2*y)not in o+k+r):
            run==False
    elif ((s[0]-x,s[1]-y)not in o+k+r)and((s[0]+x,s[1]+y)in o):
        final=judges[1]
    elif ((s[0]-x,s[1]-y)in o)and((s[0]+x,s[1]+y)in o):
        final=judges[2]
    elif ((s[0]-x,s[1]-y)in o)and((s[0]+x,s[1]+y)not in o+k+r):
        final=judges[3]
    elif ((s[0]-x,s[1]-y)in k+r)and((s[0]+x,s[1]+y)not in o+k+r):
        final=judges[4]
    elif ((s[0]-x,s[1]-y)in k+r)and((s[0]+x,s[1]+y)in o):
        final=judges[6]
    elif ((s[0]-x,s[1]-y)in o)and((s[0]+x,s[1]+y)in k+r):
        final=judges[5]
    for i in final:
        if run==True:
            will=i[0].index(3)
            length=len(i[0])
            only=True
            for right in range(will+1,length):
                d=right
                up=right-will
                if i[0][d]==1:
                    if (s[0]+up*x,s[1]+up*y)not in o:
                        only=False
                elif i[0][d]==0:
                    if (s[0]+up*x,s[1]+up*y)in o+k:
                        only=False
                elif i[0][d]==2:
                    if (s[0]+up*x,s[1]+up*y)not in k:
                        only=False
            if only==True:
                for left in range(0,will):
                    d=left
                    up=left-will
                    if i[0][d]==1:
                        if (s[0]+up*x,s[1]+up*y)not in o:
                            only=False
                    elif i[0][d]==0:
                        if (s[0]+up*x,s[1]+up*y)in o+k:
                            only=False
                    elif i[0][d]==2:
                        if (s[0]+up*x,s[1]+up*y)not in k:
                            only=False
            if only==True:
                p=i[1]
                run=False
                break

    return p
def find_lines(me,you):
    global cs,qis,qied,e
    for i in qis:
        i.s=0
        if i.xy not in qied:
            i.s+=15-abs(i.xy[0]-7)-abs(i.xy[1]-7)
    ko=0
    for i in qis:
            if i.xy not in qied:
                    re=[]
                    ree=0
                    for m in [(1,0),(1,1),(1,-1),(0,1),  (0,-1),(-1,0),(-1,-1),(-1,1)]:
                        up=int(10*3**zzz(i.xy,m[0],m[1],me,you)-10+7*3**zzz(i.xy,m[0],m[1],you,me)-7)
                        re.append(up)
                        if up>150:
                            ree+=1
                    for s in re:
                        i.s+=int((1+ree/5)*s)
            ko+=1
            if ko%2==0:
                time.sleep(0.001)
            ########################################   
    a=-1
    
    for i in qis:
            if i.xy not in qied:
                if i.s>=a:
                    a=i.s
                    d=i.xy
    return d
def find_score(me,you,t):
    global qied,qis
    qied_a=qied
    qis_a=qis
    rect=[]
    t2=time.time()
    for x in range(15):
        for y in range(15):
            if (x,y)not in qied:
                only=0
                for i in qied:
                    if ((x-i[0])**2+(y-i[0])**2)<=8:
                        only=1
                if only==1:
                    rect.append([x,y,0])
    way=[]
    zscore=0
    for x in range(15):
        for y in range(15):
            for i in qis:
                if i.xy==(x,y) and (i.xy not in qied):
                    for m in [(1,0),(1,1),(1,-1),(0,1),(0,-1),(-1,0),(-1,-1),(-1,1)]:
                                zscore+=int(10*2**zzz((x,y),m[0],m[1],me,you)-10)
            #########################################
                                zscore+=int(8*2**zzz((x,y),m[0],m[1],you,me)-8)
    print(time.time()-t2)
    qied_b=[]
    for i in me:
        qied_b.append(i[0],i[1],1)

    for me1 in rect:
        me1[2]=1
        now1=rect[:]
        now1.remove(me1)
        
        for you1 in now1:
            you1[2]=2
            now2=now1[:]
            now2.remove(you1)
            for me2 in now2:
                me2[2]=1
                now3=now2[:]
                now3.remove(me2)
                way.append([me1,you1,me2])
    for i in way:
        qied_c=qied_b[:]
        qied_c.append(i[0],i[2])

    for m in [(1,1),(1,0),(0,1),(1,-1)]:###############
        for i in qied_c:
            if (i[0]+m[0],i[1]+m[1],1)in qied_c:
                if (i[0]+2*m[0],i[1]+2*m[1],1)in qied_c:
                    if (i[0]+3*m[0],i[1]+3*m[1],1)in qied_c:
                        if(i[0]+4*m[0],i[1]+4*m[1],1)in qied_c:
                            pass
    print(time.time()-t2,zt,a)
    
    
    
    
        
    '''
    for i2 in rect:
        for i in qis:
            for m in [(1,0),(1,1),(1,-1),(0,1),(0,-1),(-1,0),(-1,-1),(-1,1)]:
                i.s+=int(10*2**zzz((i2[0],i2[1]),m[0],m[1],me,you)-10)
                i.s+=int(8*2**zzz((i2[0],i2[1]),m[0],m[1],you,me)-8)
                '''
    
def win():
    global b,w,b_s,w_s,b_w
    v=0
    if len(qied)==len(qis):
        print('平局')
        f('平局',70,250,285,122,122,122)
        v=1
        b_w+=1
    for i in b:
        if z(0,1,b) or z(1,0,b) or z(1,1,b) or z(1,-1,b):
                        print('黑赢')
                        f('黑赢',70,250,285,0,0,0)
                        v=1
                        b_s+=1
                        break
    for i in w:
        if z(0,1,w) or z(1,0,w) or z(1,1,w) or z(1,-1,w):
                        print('白赢')
                        f('白赢',70,250,285,255,255,255)
                        v=1
                        w_s+=1
                        break
    if v==0:
        return True
    elif v==1:
        return False
def close(fail):
    global b_s####
    if fail==1:
        f('认输',70,250,285,0,0,0)###color
        b_s+=1####
b_s=0
w_s=0
b_w=0



def play():
    global me_next,e,timer3
    while True:
        if e==1:
            me_next=find_lines(b,w)
            if True:
                            cs[me_next[1]][me_next[0]]=1###
                            b.append((me_next[0],me_next[1]))#黑白更改
                            qied.append((me_next[0],me_next[1]))
            e=0
            timer3=time.time()+30

def game():
    global b_s,w_s,b_w,qis,b,w,qied,fail,cs,timer,alpha,change,timer2,me_next,e,timer3,v
    while win()==True and fail==0:
        '''
        for i in cs:
            print(i)
        
        you2=int(input('列(输入一个数字):'))
        you1=int(input('行(输入一个数字):'))
        you2-=1
        you1-=1
        you_next=(you2,you1)
        '''
        back.set_alpha(alpha)
        if alpha<20:
            change=1
        elif alpha>100:
            change=0
        if change==0:
            alpha-=1
        if change==1:
            alpha+=1
        screen.fill((255,127,36))
        for i in range(39,601,40):
            pygame.draw.line(screen,(255,0,0),(39,i),(599,i),3)
        for i in range(39,601,40):
            pygame.draw.line(screen,(255,0,0),(i,39),(i,599),3)
        pos=pygame.mouse.get_pos()
        for i1 in range(40,601,40):
                    for i2 in range(40,601,40):
                        if i1-20<=pos[0] and i1+20>pos[0] and i2-20<=pos[1] and i2+20>pos[1]:
                            pygame.draw.line(screen,(0,255,0),(i1-20,i2-20),(i1-20,i2-10),4)
                            pygame.draw.line(screen,(0,255,0),(i1-20,i2+10),(i1-20,i2+20),4)
                            pygame.draw.line(screen,(0,255,0),(i1-20,i2-20),(i1-10,i2-20),4)
                            pygame.draw.line(screen,(0,255,0),(i1+10,i2-20),(i1+20,i2-20),4)
                            
                            pygame.draw.line(screen,(0,255,0),(i1+20,i2-20),(i1+20,i2-10),4)
                            pygame.draw.line(screen,(0,255,0),(i1-20,i2+20),(i1-10,i2+20),4)
                            pygame.draw.line(screen,(0,255,0),(i1+20,i2+10),(i1+20,i2+20),4)
                            pygame.draw.line(screen,(0,255,0),(i1+10,i2+20),(i1+20,i2+20),4)
        
        for event in pygame.event.get():
                if event.type==pygame.KEYDOWN:
                    if event.key==pygame.K_1:
                        w_s+=5####
                if event.type == pygame.MOUSEBUTTONDOWN:
                    mx,my=event.pos
                    if 100<mx<200 and my>610:
                        if len(b)>=1 and len(w)>=1:
                            cs[b[-1][1]][b[-1][0]]=0
                            cs[w[-1][1]][w[-1][0]]=0
                            qied.remove((b[-1][0],b[-1][1]))
                            qied.remove((w[-1][0],w[-1][1]))
                            b.remove(b[-1])
                            w.remove(w[-1])
                            fail=1
                            break
                    xx=(mx+20)//40
                    yy=(my+20)//40
                    for i in qis:
                        if i.xy==(xx-1,yy-1) and (xx-1,yy-1)not in qied:
                            you_next=(xx-1,yy-1)
                            you2=you_next[0]+1
                            you1=you_next[1]+1
                            cs[you1-1][you2-1]=2###
                            w.append((you2-1,you1-1))####
                            qied.append((you2-1,you1-1))
                            if win()==False:
                                w_s-=1###
                                break
                            timerx=time.time()
                            me_next=find_lines(b,w)#####
                            print(time.time()-timerx)
                            cs[me_next[1]][me_next[0]]=1###
                            b.append((me_next[0],me_next[1]))#黑白更改
                            qied.append((me_next[0],me_next[1]))
                            e=1
                            timer3=time.time()+30
                                       
                if event.type==pygame.QUIT:
                    fail=1
                    break
        if timer3-time.time()<0:
            fail=1
        f('{}'.format(int(timer3-time.time())),30,200,0,90,222,222)
        pygame.draw.rect(screen,(0,0,0),(50,615,100,25),5)
        f('撤回',20,70,617,30,30,30)
        screen.blit(back,(0,0))
        screen.blit(back,(0,337))
        for t in [b,w]:
            for i in t:
                for (x,y) in [(0,1),(1,0),(1,1),(1,-1)]:
                    if (i[0]+x,i[1]+y) in t:
                        p=1
                        if (i[0]+2*x,i[1]+2*y) in t:
                            p=2
                            if (i[0]+3*x,i[1]+3*y) in t:
                                p=3
                                if (i[0]+4*x,i[1]+4*y) in t:
                                    v=1
                                    p=4
                                    if(i[0]+5*x,i[1]+5*y)in t:
                                        p=5
                                        if(i[0]+6*x,i[1]+6*y)in t:
                                            p=6
                                            if(i[0]+7*x,i[1]+7*y)in t:
                                                p=7
                                                if(i[0]+8*x,i[1]+8*y)in t:
                                                    p=8
                                                    if(i[0]+9*x,i[1]+9*y)in t:
                                                        p=9
                                                        if(i[0]+10*x,i[1]+10*y)in t:
                                                            p=10
                        if p>=2:
                            #pygame.draw.line(screen,(0,0,255),(i[0]*40+40,i[1]*40+40),(i[0]*40+40+p*x*40,i[1]*40+40+p*y*40),5)
                            pass
        for i1 in range(15):
            for i2 in range(15):
                if cs[i2][i1]==1:
                    pygame.draw.circle(screen,(0,0,0),(i1*40+40,i2*40+40),15,0)
                if cs[i2][i1]==2:
                    pygame.draw.circle(screen,(255,255,255),(i1*40+40,i2*40+40),15,0)
                '''
                for i in qis:
                    if i.xy==qied[-1] and i.xy==(i1,i2):
                        f2('{}'.format(i.s//10),30,i1*40+20,i2*40+20,0,255,0)
                    if i.xy==(i1,i2) and (i.xy not in qied):
                        f2('{}'.format(i.s//10),30,i1*40+20,i2*40+20,0,255,0)'''
        if len(b)>=1:
            pygame.draw.line(screen,(0,255,0),(b[-1][0]*40+25,b[-1][1]*40+40),(b[-1][0]*40+55,b[-1][1]*40+40),3)
            pygame.draw.line(screen,(0,255,0),(b[-1][0]*40+40,b[-1][1]*40+25),(b[-1][0]*40+40,b[-1][1]*40+55),3)
        if len(w)>=1:
            pygame.draw.line(screen,(0,255,0),(w[-1][0]*40+25,w[-1][1]*40+40),(w[-1][0]*40+55,w[-1][1]*40+40),3)
            pygame.draw.line(screen,(0,255,0),(w[-1][0]*40+40,w[-1][1]*40+25),(w[-1][0]*40+40,w[-1][1]*40+55),3)
        f('白胜：{}   平局{}   黑胜：{}'.format(w_s,b_w,b_s),40,150,600,100,100,100)
        pygame.display.flip()
        time.sleep(0.04)

pko=6
def sleep():
    while True:
        print('s')
        time.sleep(1)
def wake():
    global pko
    if pko==6:
        for i1 in range(10):
            for i2 in range(10000):
                pko+=1
                pko-=1
            print(i1)
            time.sleep(1)
while True:
    c1=[0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0]
    c2=[0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0]
    c3=[0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0]
    c4=[0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0]
    c5=[0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0]

    c6=[0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0]
    c7=[0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0]
    c8=[0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0]
    c9=[0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0]
    c10=[0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0]

    c11=[0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0]
    c12=[0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0]
    c13=[0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0]
    c14=[0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0]
    c15=[0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0]
    cs=[c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15]
    b=[]
    w=[]
    qis=[]
    qied=[]
    timer=pygame.time.get_ticks()
    for i1 in range(15):
        for i2 in range(15):
            qis.append(qi((i1,i2)))
    me_next=find_lines(b,w)####
    cs[me_next[1]][me_next[0]]=1
    b.append((me_next[0],me_next[1]))#黑白更改
    qied.append((me_next[0],me_next[1]))
    signal.signal(signal.SIGINT,close)
    fail=0
    alpha=50
    change=0
    timer2=time.time()+30
    pygame.event.clear()
    timer3=time.time()+30
    
    game()
    
    pygame.mixer.music.stop()
    time.sleep(0.5)
    sound_fail.play()
    close(fail)
    for i in cs:
            print(i)
    pygame.display.flip()
    for i in range(100,400):
        pygame.draw.circle(screen,(255,174,201),(320,320),i,10)
        for event in pygame.event.get():
            pass
        time.sleep(0.03)
        pygame.display.flip()
    
